package battlenetwork;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class MyKeyListener implements KeyListener{
	private Game board;
	
	public MyKeyListener(Game board){
		this.board = board;
	}

	@Override
	public void keyPressed(KeyEvent e) {
		int code = e.getKeyCode();
		switch (code){
		//W
		case 87:	
			board.movePlayRel(Game.DIRECTION_UP);
			
			
			
			break;
		//A
		case 65:
			board.movePlayRel(Game.DIRECTION_LEFT);
			
			
			
			break;
		//S
		case 83:
			board.movePlayRel(Game.DIRECTION_DOWN);
			
			
			break;
		//D
		case 68:
			board.movePlayRel(Game.DIRECTION_RIGHT);
			
			
			
			break;
		//SPACE
		case 32:
			board.fireMain();
			
			
			
			break;
		}
		
		//System.out.println("keyPressed="+KeyEvent.getKeyText(e.getKeyCode()));
		//System.out.println(e.getKeyCode());
		
		
	}

	@Override
	public void keyReleased(KeyEvent e) {
		
	}

	@Override
	public void keyTyped(KeyEvent e) {
		
	}

}
